package cn.snowheart

/**
 * 条件语句
 *
 * @author liuwanxiang
 * @version 2019/05/31
 */
class ConditionExample {

    static void main(String[] args) {

        println("====================")

        // if - (else if) - else 判断
        int i = 10;
        if (i < 5)
            println(i + " less than 5")
        else if (i < 100)
            println(i + " greater than 5 and less than 100")
        else
            println(i + " greater than 100")

        println("====================")

        // Switch 判断
        def value = 1;
        switch (value) {
            case 1:
                println("Value is One")
                break
            case 2:
                println("Value is Two")
                break
            default:
                println("Value is Unknown")
                break
        }

        println("====================")

        // 嵌套Switch判断
        def p = 1;
        def q = 1;
        switch (p) {
            case 1:
                switch (q){
                    case 1:
                        println("q = 1 & p = 1")
                        break
                    default:
                        println("no default case~")
                        break
                }
                break
            case 2:
                println("Value is Two")
                break
            default:
                println("Value is Unknown")
                break
        }

    }

}
